
<link href="../css/font-awesome.min.css" rel="stylesheet" />
<link href="../css/H3Report/ChartBase.css" rel="stylesheet" />
<link href="../css/H3Report/bootstrap-table.min.css" rel="stylesheet" />
<link href="../css/H3Report/jquery.gritter.css" rel="stylesheet" />
<link href="../css/H3Report/msgBox.css" rel="stylesheet" />
<link href="../css/H3Report/Reporting/report.css" rel="stylesheet" />
<link href="../css/H3Report/H3-Icon-Tool/style.css" rel="stylesheet" />
<link href="../css/H3Report/IModal.css" rel="stylesheet" />
<link href="../css/H3Report/DropDownList.css" rel="stylesheet" />
<link href="../css/H3Report/zTreeStyle.css" rel="stylesheet" />
<link href="../css/bootstrap.css" rel="stylesheet" />

<script src="../js/H3Report/jquery-ui.js"></script>
<script src="../WFRes/_Scripts/jquery/jquery.lang.js" type="text/javascript"></script>

<script src="../js/H3Report/bootstraptable/bootstrap.js"></script>
<script src="../js/H3Report/bootstraptable/bootstrap-table.js"></script>
<script src="../js/H3Report/bootstraptable/bootstrap-table-zh-CN.js"></script>


<script src="../js/H3Report/Reporting/Report/ReportBase.js"></script>

<script src="../js/H3Report/Reporting/Report/ReportWidget.js"></script>
<script src="../js/H3Report/Reporting/Report/ReportSource.js"></script>
<script src="../js/H3Report/jquery.gritter.min.js"></script>
<script src="../js/H3Report/Reporting/Report/ReportDesigner.js"></script>
<script src="../js/H3Report/JqueryTree/jquery.ztree.core.js"></script>
<script src="../js/H3Report/JqueryTree/jquery.ztree.exhide.js"></script>
<script src="../js/H3Report/JqueryTree/jquery.ztree.excheck.min.js"></script>
<script src="../js/H3Report/JqueryTree/AppTree.js"></script>
<script src="../js/H3Report/H3Chart/excanvas.min.js"></script>
<script src="../js/H3Report/H3Chart/ChartBase.js"></script>
<script src="../js/H3Report/H3Chart/Chart.js"></script>
<script src="../js/H3Report/Reporting/Report/SimpleDrag.js"></script>
<script src="../js/H3Report/Reporting/Report/ReportDetail.js"></script>
<script src="../js/H3Report/Reporting/Report/ReportCombined.js"></script>
<script src="../js/H3Report/H3.plugins.system.js"></script>
<script src="../js/H3Report/Reporting/Report/SimpleBoard.js"></script>
<script src="../js/H3Report/Formula/NewFormulaEditable.js"></script>
<script src="../js/H3Report/Formula/Formula.js"></script>
<script src="../js/H3Report/sortable/Sortable.js"></script>
<script src="../js/H3Report/DropDownList/DropDownList.js"></script>
<script src="../js/H3Report/Reporting/ReportSqlSource.js"></script>
<script src="../WFRes/_Scripts/MvcSheet/MvcSheet.js"></script>
<script src="../WFRes/_Scripts/MvcSheet/MvcSheetUI.js"></script>
<script src="../WFRes/_Scripts/MvcSheet/Controls/SheetUser.js"></script>
<style>
    .icon-zuzhitubiao {
        font-family : 'LigerUIFont';
        speak : none;
        font-style : normal;
        font-weight : bold;
        font-variant : normal;
        text-transform : none;
        -webkit-font-smoothing : antialiased;
        -moz-osx-font-smoothing : grayscale;
    }
</style>
<script>
    
    $(function () {

        //该方法本该在U页面通过对象注入到当前js文件中，时间关系，先就这样，后面有时间在调整  qiancheng
        //该方法会先初始化 数据连接池下拉框数据，绑定下拉框chang事件，绑定选择视图还是表等单选按钮的事件，已经选择视图以后赋值给sql 输入框等事件方法
      //  var reportSqlSource = new $.ReportSqlSource({ sorceType: "DbConnection", lstDbConnection: "lstDbConnection", TableType: "Table", lstTables: "lstTables", lstSheet: "lstSheet" });
		var curWorkTab = top.workTab;
        var curTabID = curWorkTab.selectedTabId;
        curWorkTab.unbind("beforeRemoveTabItem" + curTabID);
		curWorkTab.bind("beforeRemoveTabItem" + curTabID, function(curTabID){
			//
			var oldReportPageString = $.ReportDesigner.oldReportPage;
			var curReportPageString = JSON.stringify($.ReportDesigner.ReportPage);
			if(oldReportPageString != curReportPageString){
				if(confirm("报表已经更改，离开当前页面？")){
					return true;
				}
				return false;
			}
		})		
    })
    var getQueryString = function (name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return unescape(r[2]);
        }
        return null;
    }
    var OpenBizSheet = function () {
        $("#ReportSourseOpen").hide();
        $("#BizSheetOpen").show();
    }
    var OpenReportSourse = function () {
        $("#ReportSourseOpen").show();
        $("#BizSheetOpen").hide();
    }
    //筛选条件显示，折叠
    var toggleFilter = function () {
        $('#h3_param_container').toggle();
        //$("div.btn-param").hide();
    }
    //保存报表模板
    var SaveReportPage = function () {
        $.ReportDesigner.SaveReport();
    };
    //页面中的部分dom对象，时间关系直接写在reportDesigner.js中，后期再做优化
    var schemaCode = getQueryString("RportCode");
    var IsDev = true;
    $.ReportDesigner.Init(schemaCode);
    //预览报表
    var ViewReportPage =function() {
        // http://localhost:16668/Portal/index.html#/app/Report/ShowReport/ddddddddd/
       var u = navigator.userAgent;
       var url = "";
       if (u.indexOf('Trident') > -1 || u.indexOf('MSIE') > -1) {
           url = window.location.host + window._PORTALROOT_GLOBAL + "/index.html#/app/Report/ShowReport/" + schemaCode + "/";
           window.open(url,"_blank")
       } else
       {
            url = window.location.origin + window._PORTALROOT_GLOBAL + "/index.html#/app/Report/ShowReport/" + schemaCode + "/";
            window.open(url);
       }

      
        
    }

    //加载数据源
    //;
    //$.ReportSourceManager.Init("EngineDatabase");
    //加载数据表列表
    //function LoadTables() {
    //    ajax($.Controller.ReportSource.LoadTables,
    //        { dbCode: "EngineDatabase" },
            
    //        function (data) {
    //            ;
                
    //            lstTables.empty();
    //            for (var i in data) {
    //                lstTables.append("<option value='" + data[i] + "'>" + data[i] + "</option>");
    //            }
    //            lstTables.val(ReportSource.TableNameOrCommandText);
    //        });
    //}

    ////加载视图列表
    //function LoadViews() {
    //    PostAjax($.Controller.ReportSource.LoadViews,
    //        { dbCode: lstDbConnection.val() },
    //        function (data) {
    //            lstTables.empty();
    //            for (var i in data) {
    //                lstTables.append("<option value='" + data[i] + "'>" + data[i] + "</option>");
    //            }
    //            lstTables.val(ReportSource.TableNameOrCommandText);
    //        });
    //}
</script>

<div class="body">
    <div class="left" style="">
        <!--<div class="top" style="width:49%!important;float:left" id="BizSheet" onclick="OpenBizSheet()">业务表单</div>-->
       
        <!-- <div class="top" style="width:50%!important;margin-left:1%; float:left" id="ReportSourse" onclick="OpenReportSourse()">数据源列表</div>-->
        <div class="top" style="" id="ReportSourse" >数据源列表</div>
        
        <div id="ReportSourseOpen" style="">
            <div id="ReportSourceZone">
                <ul class="source-collection"></ul>
            </div>
            <!--底部数据源操作-->
            <div class="source-tool">
                <div id="btnAddSource" class="save button" style="background-color: #4eca48; color: #fff; width:200px;">新增数据源</div>
            </div>
        </div>
        <!--<div id="BizSheetOpen">
            <div id="EngineSheet">
                <ul class="source-collection"></ul>
            </div>
        </div>-->
    </div>
    <div class="right">
        <div class="edit-navbar">
            <div class="edit-navbar-left">
                <!--模板区-->
                <ul id="TemplatesZone">

                </ul>

            </div>

            <div class="edit-navbar-right" id="menu" style="width:150px;">
                <div class="save button " style="background-color: #4eca48; color: #fff; float: left;" onclick="ViewReportPage()">预览</div>

                <div class="save button " style="background-color: #4eca48; color: #fff; float: left; margin-left: 10px;" onclick="SaveReportPage()">保存</div>
            </div>
        </div>
        <div class="edit-center">

            <div id="reportParameter">

                <div class="btn-param" onclick="toggleFilter()">
                    <i class="fa fa-filter"></i>
                    <span style="">设置查询条件</span>
                </div>
                <div class="h3-body" id="h3_param_container" style="">
                    <div class="myhelper" style="padding: 20px; color: grey; text-align: center;display:none; "> <span>往此处拖入字段可为报表设置查询条件</span></div>
                </div>
            </div>
            <div id="report-editor" style="min-height:450px;">
                <ul id="widget_wrapper"></ul>
                <!--此处放置一个拖动引导提示框-->
                <div class="drag-more">
                    <p style="width:100%;height:100%;vertical-align:middle;line-height:100px;margin:0px;">
                        <span style="font-size:30px;border-radius:28px;padding:5px 10px;" class="badge">1</span>
                    </p>
                </div>
            </div>
        </div>
    </div>

</div>
<!--应用树选择框-->
<div id="sheetselect" style="display:none;">
    <!--数据源显示名称-->
    <div style="width:100%;height:35px;line-height:35px;padding-left:8px;">
        <label style="font-size:14px;font-family:'Microsoft YaHei';font-weight:lighter;">数据源名称</label>
        <input id="source-display" type="text" style="float:right;width:250px;height:35px;" placeholder="请输入数据源名称" />
    </div>
    <div style="height:340px;max-height:340px;overflow-x:hidden;overflow-y:auto;">
        <div id="sheet"></div>
    </div>
</div>
<div id="editdefaultdata" style="display:none;">
    <div class="defaultdataedit" style="height:400px;width:33%;float:left;">
        <div class="defaultdataeditcontent1" style="height:80%;width:100%;">
            <textarea id="defaultdata1" style="height:100%;width:100%"></textarea>
        </div>
        <div class="defaultdataeditcontent2" style="height:20%;width:100%;">
            <textarea id="defaultdata2" style="height:100%;width:100%"></textarea>
        </div>
    </div>
    <div class="defaultdataresult" style="width:60%;height:100%;float:left;margin-left:7%;">
        <div class="defaultdataresultcontent" id="editdefaultdataresult" style="height:400px;width:600px;">

        </div>
    </div>
</div>
<div id="custom_sql" style="display:none;">
        <div style="width:20%;float:left;overflow:auto;">
            <div style="width:100%;" id="lstSheet">
                <label style="font-size:14px;font-family:'Microsoft YaHei';font-weight:lighter;" data-lang="ReportSource.DataBaseConn">数据源名称</label>
                <select id="lstDbConnection" style="height: 35px; line-height: 35px;"></select>

                <div style="padding-top: 15px; width: 100%; height: 400px; max-height: 400px; overflow-x: auto; overflow-y: auto;">
                    <div id="lstSheetTable"></div>
                </div>
               

            </div>
        </div>
        <!--数据源显示名称-->
        <div style="width:80%;float:left;padding-left:10px;">
            <div style="width:100%;height:35px;line-height:35px;padding-left:8px;">
                <div style="width:100px;float:right;height:35px;line-height:35px;display:none;">
                <input type="checkbox" id="sqlcheckwhere" />
                <label style="width:100%;font-size:14px;font-family:'Microsoft YaHei';font-weight:lighter;" for="sqlcheckwhere">设置SQL参数</label>
                </div>
                <label style="font-size:14px;font-family:'Microsoft YaHei';font-weight:lighter;">数据源名称</label>
                <input id="source-display" type="text" style="padding-left:10px; width:300px;height:35px;" placeholder="请输入数据源名称" />

            </div>
            <div class="sqlwherecontent">
                <div class="sqlwhereheader row">
                    <div class="sqlwhereheaderitem">查询条件名称</div>
                    <div class="sqlwhereheaderitem">查询条件编码</div>
                    <div class="sqlwhereheaderitem">字段数据类型</div>
                    <div class="sqlwhereheaderitemadd"><span class="fa fa-plus"></span></div>
                </div>
                <div class="sqlwhereheaderbody">

                </div>
            </div>
            <div id="sql" style="margin-top:10px;">
                <textarea class="sql" placeholder="默认第一个字段为排序字段，请知晓！"></textarea>
                <div class="msg" style="margin-top:5px;"><span class="fa fa-exclamation-circle"></span><span class="text" style="margin-right:5px;margin-left:10px;"></span><span class="check" style="float:right;color:#fff;background-color:#ee984b;width:60px;height:30px;text-align:center;padding:3px 0px;border-radius:5px;cursor:pointer;">校验</span></div>
                <div class="result" id="sqlresult" style="max-height:150px;overflow:auto;"></div>
            </div>
        </div>
    </div>
<!--手工建立关联关系-->
<div id="associationpanel">
    <!--左侧应用树，右侧关联建立-->
    <div class="panel-left"></div>
    <div class="panel-right">
        <div class="association-body-head">
            <div id="btn_addRelation" class="btn " style="background-color: #4eca48; color: #fff; margin-top: 5px; font-size: 14px; font-family: 'Microsoft YaHei'; font-weight: lighter;"><i class="fa fa-plus" style="margin-right:10px;"></i>新增关联关系</div>
        </div>
        <div class="association-body-body">
            <table class="association-table"></table>
        </div>
    </div>
</div>

<!--浮动悬浮框-->
<div class="float-panel"></div>
<!--数据源过滤框-->
<div class="source-filter-panel"></div>
<!--过滤字段编辑框-->
<div class="filter-edit-panel" id="filter-edit-panel">
    <div class="filter-name filter-wrap" style="margin-top:20px;"><label class="filter-title">显示名称</label><input class="filter-input" /></div>
    <div class="filter-type filter-wrap"><label class="filter-title">参数类型</label><select class="filter-select"></select></div>
    <div class="filter-value-string filter-wrap"><label class="filter-title">默认值</label><input class="filter-input" placeholder="多个值用';'隔开" /></div>
    <div class="filter-value-fixed filter-wrap"><label class="filter-title">固定值选项</label><input class="filter-input" placeholder='多个值用";"隔开' /></div>
    <div class="sheetuser-div filter-value-user filter-wrap" style="height:auto"><label class="filter-title">固定值选项</label><div class="filter-input" id="userChoose" style="width: 90%"></div></div>
    <div class="sheetuser-div filter-value-organization filter-wrap" style="height:auto"><label class="filter-title">固定值选项</label><div class="filter-input" id="organizationChoose" style="width: 90%"></div></div>
    <div class="sheetuser-div filter-value-all filter-wrap" style="height:auto"><label class="filter-title">固定值选项</label><div class="filter-input" id="allChoose" style="width: 90%"></div></div>
    <div class="filter-value-select filter-wrap"><label class="filter-title">默认值</label><select class="filter-select"></select></div>
    <div class="filter-MasterData filter-wrap"><label class="filter-title">数据字典选项</label><select class="filter-select"></select></div>
    <div class="filter-organizationtype filter-wrap">
        <label class="filter-title">组织类型</label>
        <select class="filter-select">
            <option value="0">人员</option>
            <option value="1">部门</option>
            <option value="2">全部</option>
        </select>
    </div>
    <div class="filter-allownull" style="margin-top:5px;padding-left:5%; width:50%;"><input class="filter-checkbox" id="myexportallowrequered" type="checkbox"><label style="font-weight:normal;width:100%;" for="myexportallowrequered">允许为空</label></div>
    <div class="filter-visible" style="padding-left:5%; width:50%; float:left;"><input class="filter-checkbox" type="checkbox" id="myexportshow"><label style="font-weight:normal;width:100%;" for="myexportshow">是否显示</label></div>

</div>
<div class="filter-edit-footer" id="myfiltereditfooter">
    <button type="button" class="masBox-btn btn_ok">确认</button>
    <button type="button" class="masBox-btn btn_cancel">取消</button>
</div>
<!--浮动字段编辑框-->
<div id="float-panel-field-eidt" style="display:none;">
    <div style="width:100%;height:80%;overflow:auto;">
        <div class="displayname" style="text-align:center;">
            <label style="font-weight:bold;">显示名称</label>
            <input style="width:100%;" id="displayname" type="text" />
        </div>

        <div class="functiontypeofnum" style="text-align:center;">
            <label style="font-weight:bold;">函数类型</label>
            <select id="numfunc" style="display:block;width:100%;">
                <!-- update by ouyangsk -->
                <!-- 隐藏空行 -->
                <!-- <option value="-1"></option> -->
                <option value="0">Count</option>
                <option value="1">Sum</option>
                <option value="2">Avg</option>
                <option value="3">Min</option>
                <option value="4">Max</option>
            </select>
        </div>
        <div class="functiontypeofdate">
            <label>函数类型</label>
            <select id="datefunc">
                <option value="5">年</option>
                <option value="8">年-季度</option>
                <option value="6">年-月</option>
                <option value="7">年-月-日</option>
            </select>
        </div>
        <div class="formula">
            <label>公式</label>
            <span id="formula" class="fa fa-facebook" style="color:blue;margin-left:5px;"></span>
            <label class="myedit" style="color:blue;cursor:pointer;">编辑公式</label>
        </div>
        <div class="formattype">
            <label>数据格式</label>
            <select id="columndataformat" style="display:block;width:100%;">
                <option value="0">预定义格式</option>
                <option value="1">自定义定义格式</option>
            </select>
        </div>
        <div class="customformat" style="text-align:center;">
            <input id="format" type="text" />
        </div>
        <div class="dateformat">
            <label>数据格式</label>
            <select id="date_format" style="display:block;width:100%;">
                <option value="yyyy-MM-dd">2016-01-01</option>
                <option value="yyyy-MM-dd HH:mm:ss">2016-01-01 01:01:01</option>
                <option value="yyyy-MM-dd HH:mm">2016-01-01 01:01</option>
                <option value="yyyy-MM-dd HH">2016-01-01 01</option>
                <option value="yyyy/MM/dd">2016/01/01</option>
                <option value="yyyy/MM/dd HH:mm:ss">2016/01/01 01:01:01</option>
                <option value="yyyy/MM/dd HH:mm">2016/01/01 01:01</option>
                <option value="yyyy/MM/dd HH">2016/01/01 01</option>
                <option value="yyyy年M月d日">2016年1月1日</option>
                <option value="yyyy年M月d日 HH时mm分ss秒">2016年1月1日01时01分01秒</option>
                <option value="yyyy年M月d日 HH时mm分">2016年1月1日01时01分</option>
                <option value="yyyy年M月d日 HH时">2016年1月1日01时</option>
                <option value="yyyy年M月d日 EEE">2016年1月1日 星期五</option>
                <option value="yyyy年M月">2016年1月</option>
            </select>
        </div>
        <div class="numberformat">
            <div>
                <input id="thoudsandth" type="checkbox" /><label for="thoudsandth" style="width:100%">千分位</label>
            </div>
            <div>
                <input id="percentage" type="checkbox" /><label for="percentage" style="width:100%">百分比</label>

            </div>
            <div>
                <input id="precision" type="checkbox" /><label for="precision" style="width:30%">小数位数</label>
                <div>
                    <input id="digits" type="text" style="width:30%;" onpaste="return false();" onkeypress="onlyDigital(event)" />
                </div>
            </div>

        </div>
    </div>
    <div style="text-align:center;" id="myfieldbutton">
        <button type="button" class="masBox-btn btn_ok">确认</button>
        <button type="button" class="masBox-btn btn_cancel">取消</button>
    </div>
</div>
<!--添加排序字段-->
<div id="sortcolumns">
    <ul class="columns"></ul>
</div>

<div class="linkage-widget">
</div>
<div class="container-formula">
    <input type="text" id="formula" style="display:none;" />
</div>
<div class="simpleboard-column-edit"></div>

<div class="simpleboard-column-remove" style="display:none;">
    <ul>
        <li class="td-remove">删除数据</li>
        <li class="row-remove">删除本行</li>
        <li class="col-remove">删除本列</li>
    </ul>
</div>
